$(function() {
	var ohtml=document.documentElement;
	getSize();
	window.onresize=function(){
		getSize();
	};
	function getSize(){
		var screenWidth=ohtml.clientWidth;
		if(screenWidth<=320){
			ohtml.style.fontSize='20px';
		}else if(screenWidth>=640){
			ohtml.style.fontSize='40px';
		}else{
			ohtml.style.fontSize=screenWidth/(640/40)+'px';
		}
	}

});
//获取get参数
function GetQueryString(name) {
	var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r!=null)
		return  decodeURI(r[2]);
	return null;
}

/*
 * 获取客户浏览器信息
 * */
var browser = {
    versions: function () {
        var u = navigator.userAgent, app = navigator.appVersion;
        return {         //移动终端浏览器版本信息
            trident: u.indexOf('Trident') > -1, //IE内核
            presto: u.indexOf('Presto') > -1, //opera内核
            webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
            gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
            mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
            iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
            iPad: u.indexOf('iPad') > -1, //是否iPad
            webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
        };
    }(),
    language: (navigator.browserLanguage || navigator.language).toLowerCase()
};

function myrefresh(){
    window.location.reload();
}

/*
 * 获取手机型号函数begin
 * */
function getPhoneType(){
    //正则,忽略大小写
    var pattern_phone = new RegExp("iPhone","i");
    var pattern_android = new RegExp("android","i");
    var userAgent = navigator.userAgent.toLowerCase();
    var isAndroid = pattern_android.test(userAgent);
    var isIphone = pattern_phone.test(userAgent);
    var phoneType="phoneType";
    if(isAndroid){
        var zh_cnIndex = userAgent.indexOf("-");
        var spaceIndex = userAgent.indexOf("build",zh_cnIndex+4);
        var fullResult = userAgent.substring(zh_cnIndex,spaceIndex);
        phoneType=fullResult.split(";")[1];
    }else if(isIphone){
        //6   w=375    6plus w=414   5s w=320     5 w=320
        var wigth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
        if(wigth>400){
            phoneType = "iPhone6plus";
        }else if(wigth>370){
            phoneType = "iphone6";
        }else if(wigth>315){
            phoneType = "iphone5";
        }else{
            phoneType = "iphone4";
        }


    }else{
        phoneType = "您的设备太先进了";
    }
//            alert(phoneType);
    return phoneType;
}


//制止a链接跳转
function stopDefault(e) {
    if (e && e.preventDefault)
        e.preventDefault();
    else
        window.event.returnValue = false;
}
// 页面链接跳转历史URL不记录的兼容处理
//其中eleLink参数表示<a>链接DOM元素
// document.getElementsByTagName('a')[0].onclick = function (event) {
//     stopDefault(event);
//     fnUrlReplace(this);
//     return false;
// };
var fnUrlReplace = function (eleLink) {
    if (!eleLink) {
        return;
    }
    var href = eleLink.href;
    if (href && /^#|javasc/.test(href) === false) {
        if (history.replaceState) {
            history.replaceState(null, document.title, href.split('#')[0] + '#');
            location.replace('');
        } else {
             location.replace(href);
        }
    }
};


$.fn.extend({

    /*下拉菜单*/
    downMenu: function (time, dwntg, css) {
        this.mouseenter(function () {
            var menu = $(this).next();
            var downMenu = menu.find(dwntg);
            dlTime = setTimeout(function () {
                menu.addClass(css);
                downMenu.slideDown(time);
            },
                100);
        }).mouseleave(function () {
            var menu = $(this).next();
            var downMenu = menu.find(dwntg);
            clearTimeout(dlTime);
            downMenu.hide();
            menu.removeClass(css);
        });
    }

});

//    $('.jyjlDetails').downMenu(100, '.det', 'on');